﻿using UnityEngine;
using System.Collections;

public class action : MonoBehaviour
{

	


	Ray ray;
	RaycastHit hit;
	// Use this for initialization
	void Start ()
	{
		//GameObject c = GameObject.Find ("Cube2");

	}
	
	// Update is called once per frame
	void Update ()
	{
		if (Input.GetKey (KeyCode.Mouse0)) {
			ray = Camera.main.ScreenPointToRay (Input.mousePosition);
			if (Physics.Raycast (ray, out hit)) {
				print (hit.transform.name.ToString ());
				bool key = false;
				if (hit.transform.name.ToString () == "Plane") {
					key = true;
				}

				if (hit.transform.name.ToString () == "Cube") {
					key = true;
				}

				if (hit.transform.name.ToString () == "Cube2") {
					key = true;
				}

				//print (key);
				if (key == false) {
					Destroy (hit.collider.gameObject);
				}
			}
		}
	}
}
